<?

//随机数生成函数
function get_rand($maxv) {
	return mt_rand(1,$maxv);
}

function rcolor() {
	$pattern='1234567890abcdef';
        for ($i=0; $i<6; $i++)
        {
            $key.=$pattern {mt_rand(0,15)};
        }
        return $key;
}

function shuffle_assoc($array) {
	if (count($array)>1) {
		$new = array();
		//echo $keys."\n";
		foreach($array as $ar) {
			$key = array_rand($array);
			$new[$key] = $array[$key];
			unset($array[$key]);
		}
	}
	return $new;
}

/*$ps = array (
	'SSK' => '86',
	'XP' => '79',
	'神杀' => '92',
	);
  mech = 1(R)/2(T)/3(Z)
*/
function get_order($ps,$mech=3) {
	foreach($ps as $k=>$v) {
		if($v < 15) {
			$ps[$k] = 15;
		}
	}
	$ps = shuffle_assoc($ps);
	switch($mech) {
//		case 1:{$orderlist = order_r($ps);break;}
//		case 2:{$orderlist = order_t($ps);break;}
		case 3:{$orderlist = order_z($ps);break;}
	}
	return $orderlist;
}

function order_z($ps) {
	$pas = array_keys($ps);
	$sas = array_values($ps);
	foreach($ps as $k=>$v) {
		$d10total = 0;
		for($i=0;$i<10;$i++) {
			$d10total += get_rand(10);
		}
		$ps[$k] += $d10total;
	}
	arsort($ps,SORT_NUMERIC);
	return $ps;
}

?>
